package main

import (
	"erasure-service/api"
	"os"

	"github.com/kataras/iris/v12"
	"github.com/kataras/iris/v12/middleware/accesslog"
)

func main() {

	ac := accesslog.File("./access.log")
	defer ac.Close()
	ac.AddOutput(os.Stdout)
	ac.Delim = '|'
	ac.TimeFormat = "2006-01-02 15:04:05"
	ac.Async = false
	ac.IP = true
	ac.BytesReceivedBody = false
	ac.BytesSentBody = false
	ac.BytesReceived = true
	ac.BytesSent = true
	ac.BodyMinify = true
	ac.RequestBody = false
	ac.ResponseBody = false
	ac.KeepMultiLineError = true
	ac.PanicLog = accesslog.LogHandler
	app := iris.New()
	app.UseRouter(ac.Handler)

	app.Post("/client-api/file", api.Encode)
	app.Post("/client-api/file/{name}/{size}", api.Decode)
	app.Get("/clear", api.ClearCache)
	app.Listen(":8000")
}
